package com.woniuxy03;

import java.io.File;
import java.io.IOException;

/**
 * @author 作者
 * @create 2025-11-10 16:36
 */
public class Test01 {
    public static void main(String[] args) throws IOException {
        File file = new File("d:\\aaa");
        File[] files = file.listFiles();
        for(File myfile : files){
            System.out.println(myfile);
            System.out.println(myfile.getAbsolutePath());
            System.out.println("----------------");
        }
    }

    private static void test05() {
        File file = new File("d:\\aaa");
        //返回当前目录中所有的文件和目录的名字
        String[] list = file.list();
        for(String str : list){
            System.out.println(str);
        }
    }

    private static void test04() throws IOException {
        File file = new File("d:\\aaa\\b.txt");
        file.createNewFile();
    }

    private static void test03() {
        File file = new File("d:\\bbb\\b1\\b2\\b3\\b4");
        //创建目录,要求上级目录必须存在
//        file.mkdir();
        //上次目录不存在，会自动创建
        file.mkdirs();
    }

    private static void test01() {
        //目录对象
        File file1=new File("d:\\aaa");
        //文件对象
        File file2=new File("d:\\aaa\\a.txt");
        System.out.println(file1.isFile());
        System.out.println(file1.isDirectory());
        System.out.println(file2.isFile());
        System.out.println(file2.isDirectory());
    }
}
